package com.yangzb.sample.kafka;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import org.apache.kafka.clients.producer.*;
import org.apache.kafka.common.serialization.StringSerializer;
import top.chaser.framework.common.base.util.JSONUtil;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * @date 2022/11/2 14:39
 */
public class KafkaProducerDemo {
    public static void main(String[] args) {
//        test1();
//        test2();
//        scrta1();
//        scrta2();
        scrta();
//        tongji();
    }

    private static void scrta2() {
        //1.创建kafka生产者配置对象
        Properties props = new Properties();
        //2.给 kafka 配置对象添加配置信息：bootstrap.servers
//        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.15:6667,192.168.10.16:6667,192.168.10.17:6667");
        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.156:6667,192.168.10.157:6667,192.168.10.158:6667");
        //key,value 序列化（必须）
        //把发送的key从字符串序列化为字节数组
        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        //把发送消息value从字符串序列化为字节数组
        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        props.put(ProducerConfig.ACKS_CONFIG, "all");
        // 3. 创建 kafka 生产者对象
        Producer<String, String> producer = new KafkaProducer<>(props);


        for (int i = 0; i < 2; i++) {
            //4. 调用 send 方法,发送消息
            RecordMetadata metadata = null;
            try {
                String data = "{\n" +
                        "    \"eventInput\": {\n" +
                        "        \"event_content\": {\n" +
                        "            \"average_outset_fee\": 0.25,\n" +
                        "            \"recommend_times\": 5\n" +
                        "        },\n" +
                        "        \"event_id\": \"1000195\",\n" +
                        "        \"evtInstId\": 2308613794290000,\n" +
                        "        \"label_content\": {\n" +
                        "            \"REGION_ID\": \"8510400\",\n" +
                        "            \"USER_IS_SPEEDDOWD_D\": 1,\n" +
                        "            \"B85110A0200103140\": 15,\n" +
                        "            \"black_mark_flag\": \"0\",\n" +
                        "            \"B85110A0200103141\": 1,\n" +
                        "            \"B85110A0200103133\": \"2023-03-23 14:58:18\",\n" +
                        "            \"serv_id\": \"620043318599\",\n" +
                        "            \"T_SCS_SFBXLTC\": 1,\n" +
                        "            \"T10000001\": \"18081738100\",\n" +
                        "            \"T10000002\": \"620021291100\",\n" +
                        "            \"tid\": \"620043318593\",\n" +
                        "            \"red_mark_flag\": \"0\",\n" +
                        "            \"B85110A0200101708\": \"HuangGuiChun\",\n" +
                        "            \"custId\": \"620021291100\",\n" +
                        "            \"B85110A0200103135\": 21.5,\n" +
                        "            \"link_acc_nbr\": \"18081738100\",\n" +
                        "            \"B85110A0200103134\": \"2023-01-23 14:58:18\",\n" +
                        "            \"B85110A0200103137\": 29.5,\n" +
                        "            \"B85110A0200103136\": 100,\n" +
                        "            \"B85110A0200103139\": 20,\n" +
                        "            \"tp\": 1,\n" +
                        "            \"B85110A0200103138\": 25.5,\n" +
                        "            \"LINK_NBR\": \"18081738100\",\n" +
                        "            \"B85110B0200101980\": \"wm3UnLCAAAJnrvBqIAohz0bMdmOY_OkQ\"\n" +
                        "        },\n" +
                        "        \"event_time\": \"2023-03-27 17:07:56\",\n" +
                        "        \"event_target\": {\n" +
                        "            \"ev_target_obj_type\": \"1000\",\n" +
                        "            \"ev_from_type\": \"lifecycle\",\n" +
                        "            \"ev_region_id\": \"8510400\",\n" +
                        "            \"ev_target_obj_nbr\": \"620043318599\",\n" +
                        "            \"ev_mob_acc_nbr\": \"18081738100\",\n" +
                        "            \"ev_split_log_id\": 2308613794290000,\n" +
                        "            \"evt_serial_num\": 2308613794290000\n" +
                        "        }\n" +
                        "    },\n" +
                        "    \"contactOrder\": {\n" +
                        "        \"statusDate\": \"2023-04-06 10:30:00\",\n" +
                        "        \"mktCampaignScptId\": \"1001121\",\n" +
                        "        \"mktCampaignId\": \"10001285\",\n" +
                        "        \"contactOrderId\": \"\",\n" +
                        "        \"statusCd\": \"1000\",\n" +
                        "        \"targetObjNbr\": \"620043318599\",\n" +
                        "        \"waveId\": \"\",\n" +
                        "        \"procDefId\": \"\",\n" +
                        "        \"targetObjName\": \"\",\n" +
                        "        \"expDate\": \"2023-04-09 10:30:00\",\n" +
                        "        \"tarGrpId\": \"100001978\",\n" +
                        "        \"effDate\": \"2023-03-23 00:00:00\",\n" +
                        "        \"campainType\": \"1000\",\n" +
                        "        \"contactOrderItem\": [\n" +
                        "        ],\n" +
                        "        \"contactScript\": \"不满足策略条件\",\n" +
                        "        \"customerLableBean\": [\n" +
                        "            {\n" +
                        "                \"col\": \"COL_1\",\n" +
                        "                \"injectionLabelValue\": \"18081738100\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_2\",\n" +
                        "                \"injectionLabelValue\": \"620021291100\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_3\",\n" +
                        "                \"injectionLabelValue\": \"620043318599\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_4\",\n" +
                        "                \"injectionLabelValue\": \"8510400\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_5\",\n" +
                        "                \"injectionLabelValue\": \"18081738100\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_6\",\n" +
                        "                \"injectionLabelValue\": \"0\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_7\",\n" +
                        "                \"injectionLabelValue\": \"0\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_8\",\n" +
                        "                \"injectionLabelValue\": \"1\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_9\",\n" +
                        "                \"injectionLabelValue\": \"1\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_10\",\n" +
                        "                \"injectionLabelValue\": \"2023-03-23 14:58:18\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_12\",\n" +
                        "                \"injectionLabelValue\": \"HuangGuiChun\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_13\",\n" +
                        "                \"injectionLabelValue\": \"wm3UnLCAAAJnrvBqIAohz0bMdmOY_OkQ\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_15\",\n" +
                        "                \"injectionLabelValue\": \"2023-01-23 14:58:18\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_16\",\n" +
                        "                \"injectionLabelValue\": \"21.5\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_17\",\n" +
                        "                \"injectionLabelValue\": \"100.0\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_18\",\n" +
                        "                \"injectionLabelValue\": \"29.5\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_19\",\n" +
                        "                \"injectionLabelValue\": \"25.5\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_20\",\n" +
                        "                \"injectionLabelValue\": \"20.0\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_21\",\n" +
                        "                \"injectionLabelValue\": \"15.0\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_22\",\n" +
                        "                \"injectionLabelValue\": \"1\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_11\",\n" +
                        "                \"injectionLabelValue\": \"5\"\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"col\": \"COL_14\",\n" +
                        "                \"injectionLabelValue\": \"0.25\"\n" +
                        "            }\n" +
                        "        ],\n" +
                        "        \"regionId\": \"8510400\",\n" +
                        "        \"evtInstId\": \"2308613794290000\",\n" +
                        "        \"chnGrpId\": \"100001986\",\n" +
                        "        \"contactChlId\": \"10006741\",\n" +
                        "        \"cycleCode\": \"\",\n" +
                        "        \"targetObjType\": \"1000\"\n" +
                        "    }\n" +
                        "}";
                ProducerRecord<String, String> producerRecord = new ProducerRecord<>("bss-rta-rule-flink-dev-3", data);
                producer.send(producerRecord);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        producer.close();

    }

    private static void scrta1() {
        //1.创建kafka生产者配置对象
        Properties props = new Properties();
        //2.给 kafka 配置对象添加配置信息：bootstrap.servers
//        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.15:6667,192.168.10.16:6667,192.168.10.17:6667");
        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.156:6667,192.168.10.157:6667,192.168.10.158:6667");
        //key,value 序列化（必须）
        //把发送的key从字符串序列化为字节数组
        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        //把发送消息value从字符串序列化为字节数组
        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        props.put(ProducerConfig.ACKS_CONFIG, "all");
        // 3. 创建 kafka 生产者对象
        Producer<String, String> producer = new KafkaProducer<>(props);


        for (int i = 0; i < 1000; i++) {
            //4. 调用 send 方法,发送消息
            RecordMetadata metadata = null;
            try {
                String data = "{\n" +
                        "  \"eventInput\" : {\n" +
                        "    \"event_content\" : {\n" +
                        "      \"average_outset_fee\" : 0.25,\n" +
                        "      \"recommend_times\" : 5\n" +
                        "    },\n" +
                        "    \"event_id\" : \"1000195\",\n" +
                        "    \"label_content\" : {\n" +
                        "      \"REGION_ID\" : \"8510400\",\n" +
                        "      \"USER_IS_SPEEDDOWD_D\" : 1,\n" +
                        "      \"black_mark_flag\" : \"0\",\n" +
                        "      \"B85110A0200103140\" : 15.0,\n" +
                        "      \"B85110A0200103141\" : 1,\n" +
                        "      \"B85110A0200103133\" : \"2023-03-23 14:58:18\",\n" +
                        "      \"serv_id\" : \"620043318599\",\n" +
                        "      \"T_SCS_SFBXLTC\" : 1,\n" +
                        "      \"T10000001\" : \"18081738100\",\n" +
                        "      \"T10000002\" : \"620021291100\",\n" +
                        "      \"tid\" : \"620043318593\",\n" +
                        "      \"red_mark_flag\" : \"0\",\n" +
                        "      \"B85110A0200101708\" : \"HuangGuiChun\",\n" +
                        "      \"B85110A0200103135\" : 21.5,\n" +
                        "      \"custId\" : \"620021291100\",\n" +
                        "      \"link_acc_nbr\" : \"18081738100\",\n" +
                        "      \"B85110A0200103134\" : \"2023-01-23 14:58:18\",\n" +
                        "      \"B85110A0200103137\" : 29.5,\n" +
                        "      \"B85110A0200103136\" : 100.0,\n" +
                        "      \"B85110A0200103139\" : 20.0,\n" +
                        "      \"tp\" : 1,\n" +
                        "      \"B85110A0200103138\" : 25.5,\n" +
                        "      \"LINK_NBR\" : \"18081738100\",\n" +
                        "      \"B85110B0200101980\" : \"wm3UnLCAAAJnrvBqIAohz0bMdmOY_OkQ\"\n" +
                        "    },\n" +
                        "    \"event_time\" : \"2023-03-27 17:07:56\",\n" +
                        "    \"event_target\" : {\n" +
                        "      \"ev_target_obj_type\" : \"1000\",\n" +
                        "      \"ev_from_type\" : \"lifecycle\",\n" +
                        "      \"ev_region_id\" : \"8510400\",\n" +
                        "      \"ev_target_obj_nbr\" : \"620043318599\",\n" +
                        "      \"ev_mob_acc_nbr\" : \"18081738100\",\n" +
                        "      \"ev_split_log_id\" : 2308613794290000,\n" +
                        "      \"evt_serial_num\" : 2308613794290000\n" +
                        "    },\n" +
                        "    \"evtInstId\" : 2308613794290000\n" +
                        "  },\n" +
                        "  \"eventInfoMap\" : {\n" +
                        "    \"evt_mapped_addr\" : \"\",\n" +
                        "    \"status_date\" : 1678948290000,\n" +
                        "    \"event_trig_type\" : \"1000\",\n" +
                        "    \"mkt_cam_evt_rel\" : [ {\n" +
                        "      \"status_date\" : 1679539230000,\n" +
                        "      \"event_id\" : 1000195,\n" +
                        "      \"lan_id\" : null,\n" +
                        "      \"status_cd\" : \"1000\",\n" +
                        "      \"mkt_camp_evt_rel_id\" : 1000097,\n" +
                        "      \"create_staff\" : 1,\n" +
                        "      \"remark\" : \"\",\n" +
                        "      \"update_staff\" : 1,\n" +
                        "      \"create_date\" : 1679539230000,\n" +
                        "      \"update_date\" : 1679539230000,\n" +
                        "      \"mkt_campaign_id\" : 10001285\n" +
                        "    } ],\n" +
                        "    \"evt_type_id\" : 84,\n" +
                        "    \"interface_cfg_id\" : 1000316,\n" +
                        "    \"create_staff\" : 1,\n" +
                        "    \"remark\" : \"\",\n" +
                        "    \"update_staff\" : 1,\n" +
                        "    \"evt_mapped_fun_name\" : \"\",\n" +
                        "    \"update_date\" : 1678948290000,\n" +
                        "    \"event_desc\" : \"\",\n" +
                        "    \"event_id\" : 1000195,\n" +
                        "    \"ext_event_id\" : null,\n" +
                        "    \"status_cd\" : \"1000\",\n" +
                        "    \"evt_mapped_ip\" : \"\",\n" +
                        "    \"evtInstId\" : 2308613794290000,\n" +
                        "    \"event_match_rul\" : [ {\n" +
                        "      \"evt_rul_desc\" : null,\n" +
                        "      \"status_date\" : 1678948284000,\n" +
                        "      \"evt_match_rul_id\" : 1000199,\n" +
                        "      \"create_staff\" : 1,\n" +
                        "      \"remark\" : null,\n" +
                        "      \"update_staff\" : null,\n" +
                        "      \"update_date\" : 1678948284000,\n" +
                        "      \"event_id\" : 1000195,\n" +
                        "      \"evt_rul_handle_class\" : null,\n" +
                        "      \"status_cd\" : \"1000\",\n" +
                        "      \"evt_rul_name\" : null,\n" +
                        "      \"evt_rul_expression\" : \"{\\\"cnSql\\\":\\\"\\\",\\\"sql\\\":\\\"\\\",\\\"hiveSql\\\":\\\"\\\",\\\"json\\\":\\\"{}\\\"}\",\n" +
                        "      \"create_date\" : 1678948284000\n" +
                        "    } ],\n" +
                        "    \"event_name\" : \"达量限速@生命周期\",\n" +
                        "    \"evt_procotol_type\" : \"\",\n" +
                        "    \"create_date\" : 1678701111000,\n" +
                        "    \"event_nbr\" : \"2103599155\",\n" +
                        "    \"event_item\" : [ {\n" +
                        "      \"evt_item_id\" : 10002198,\n" +
                        "      \"evt_item_from_type\" : \"EVENT\",\n" +
                        "      \"evt_item_code\" : \"recommend_times\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"当前推荐次数\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002202,\n" +
                        "      \"evt_item_from_type\" : \"EVENT\",\n" +
                        "      \"evt_item_code\" : \"average_outset_fee\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"近6个月限速月平均套外费用\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002186,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"T10000001\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"用户接入号\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002187,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"T10000002\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"客户ID\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002188,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"serv_id\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"用户ID（目标对象标识）\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002189,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"REGION_ID\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"集团地市编码\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002190,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"LINK_NBR\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"优先组号码\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002191,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"black_mark_flag\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"黑名单\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002192,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"red_mark_flag\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"红名单\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002193,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"T_SCS_SFBXLTC\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"用户是否不限量套餐\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002194,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103141\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"是否普通用户达量80%\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002195,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103133\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"初次流量限速时间\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002199,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200101708\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"企业号ID\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002200,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110B0200101980\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"客户ID或者群ID\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002203,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103134\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"用户订购促销流量包时间\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002204,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103135\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"T-1月套外费用\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002205,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103136\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"T-2月套外费用\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002206,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103137\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"T-3月套外费用\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002207,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103138\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"T-4月套外费用\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002208,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103139\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"T-5月套外费用\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002209,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"B85110A0200103140\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"T-6月套外费用\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    }, {\n" +
                        "      \"evt_item_id\" : 10002210,\n" +
                        "      \"evt_item_from_type\" : \"LABEL\",\n" +
                        "      \"evt_item_code\" : \"USER_IS_SPEEDDOWD_D\",\n" +
                        "      \"is_nullable\" : 1,\n" +
                        "      \"evt_item_name\" : \"当前C网用户是否降速\",\n" +
                        "      \"evt_item_format\" : null\n" +
                        "    } ]\n" +
                        "  },\n" +
                        "  \"rtaRulelabelMap\" : {\n" +
                        "    \"eventInstItemList\" : [ {\n" +
                        "      \"item_code\" : \"recommend_times\",\n" +
                        "      \"item_id\" : \"10002198\",\n" +
                        "      \"item_value\" : \"5\"\n" +
                        "    }, {\n" +
                        "      \"item_code\" : \"average_outset_fee\",\n" +
                        "      \"item_id\" : \"10002202\",\n" +
                        "      \"item_value\" : \"0.25\"\n" +
                        "    } ],\n" +
                        "    \"injectionlableList\" : [ {\n" +
                        "      \"injectionLabelCode\" : \"T10000001\",\n" +
                        "      \"injectionLabelValue\" : \"18081738100\",\n" +
                        "      \"injectionLabelId\" : \"10002186\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"T10000002\",\n" +
                        "      \"injectionLabelValue\" : \"620021291100\",\n" +
                        "      \"injectionLabelId\" : \"10002187\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"serv_id\",\n" +
                        "      \"injectionLabelValue\" : \"620043318599\",\n" +
                        "      \"injectionLabelId\" : \"10002188\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"REGION_ID\",\n" +
                        "      \"injectionLabelValue\" : \"8510400\",\n" +
                        "      \"injectionLabelId\" : \"10002189\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"LINK_NBR\",\n" +
                        "      \"injectionLabelValue\" : \"18081738100\",\n" +
                        "      \"injectionLabelId\" : \"10002190\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"black_mark_flag\",\n" +
                        "      \"injectionLabelValue\" : \"0\",\n" +
                        "      \"injectionLabelId\" : \"10002191\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"red_mark_flag\",\n" +
                        "      \"injectionLabelValue\" : \"0\",\n" +
                        "      \"injectionLabelId\" : \"10002192\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"T_SCS_SFBXLTC\",\n" +
                        "      \"injectionLabelValue\" : \"1\",\n" +
                        "      \"injectionLabelId\" : \"10002193\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103141\",\n" +
                        "      \"injectionLabelValue\" : \"1\",\n" +
                        "      \"injectionLabelId\" : \"10002194\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103133\",\n" +
                        "      \"injectionLabelValue\" : \"2023-03-23 14:58:18\",\n" +
                        "      \"injectionLabelId\" : \"10002195\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200101708\",\n" +
                        "      \"injectionLabelValue\" : \"HuangGuiChun\",\n" +
                        "      \"injectionLabelId\" : \"10002199\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110B0200101980\",\n" +
                        "      \"injectionLabelValue\" : \"wm3UnLCAAAJnrvBqIAohz0bMdmOY_OkQ\",\n" +
                        "      \"injectionLabelId\" : \"10002200\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103134\",\n" +
                        "      \"injectionLabelValue\" : \"2023-01-23 14:58:18\",\n" +
                        "      \"injectionLabelId\" : \"10002203\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103135\",\n" +
                        "      \"injectionLabelValue\" : \"21.5\",\n" +
                        "      \"injectionLabelId\" : \"10002204\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103136\",\n" +
                        "      \"injectionLabelValue\" : \"100.0\",\n" +
                        "      \"injectionLabelId\" : \"10002205\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103137\",\n" +
                        "      \"injectionLabelValue\" : \"29.5\",\n" +
                        "      \"injectionLabelId\" : \"10002206\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103138\",\n" +
                        "      \"injectionLabelValue\" : \"25.5\",\n" +
                        "      \"injectionLabelId\" : \"10002207\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103139\",\n" +
                        "      \"injectionLabelValue\" : \"20.0\",\n" +
                        "      \"injectionLabelId\" : \"10002208\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"B85110A0200103140\",\n" +
                        "      \"injectionLabelValue\" : \"15.0\",\n" +
                        "      \"injectionLabelId\" : \"10002209\"\n" +
                        "    }, {\n" +
                        "      \"injectionLabelCode\" : \"USER_IS_SPEEDDOWD_D\",\n" +
                        "      \"injectionLabelValue\" : \"1\",\n" +
                        "      \"injectionLabelId\" : \"10002210\"\n" +
                        "    } ]\n" +
                        "  }\n" +
                        "}";
                ProducerRecord<String, String> producerRecord = new ProducerRecord<>("bss-rta-rule-flink-dev-2", data);
                producer.send(producerRecord);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        producer.close();

    }

    private static void scrta() {
        //1.创建kafka生产者配置对象
        Properties props = new Properties();
        //2.给 kafka 配置对象添加配置信息：bootstrap.servers
//        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.15:6667,192.168.10.16:6667,192.168.10.17:6667");
        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.156:6667,192.168.10.157:6667,192.168.10.158:6667");
        //key,value 序列化（必须）
        //把发送的key从字符串序列化为字节数组
        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        //把发送消息value从字符串序列化为字节数组
        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        props.put(ProducerConfig.ACKS_CONFIG, "all");
        // 3. 创建 kafka 生产者对象
        Producer<String, String> producer = new KafkaProducer<>(props);


        for (int i = 0; i < 200000; i++) {
            //4. 调用 send 方法,发送消息
            RecordMetadata metadata = null;
            try {
                String data = "{\n" +
                        "  \"event_id\": \"1000195\",\n" +
                        "  \"event_time\": \"2023-03-27 17:07:56\",\n" +
                        "  \"event_target\": {\n" +
                        "    \"ev_mob_acc_nbr\": \"18081738100\",\n" +
                        "    \"ev_region_id\": \"8510400\",\n" +
                        "    \"ev_target_obj_type\": \"1000\",\n" +
                        "    \"ev_target_obj_nbr\": \"620043318599\",\n" +
                        "    \"ev_split_log_id\": " + i + ",\n" +
                        "    \"evt_serial_num\": 2308613794290000,\n" +
                        "    \"ev_from_type\": \"lifecycle\"\n" +
                        "  },\n" +
                        "  \"event_content\": {\n" +
                        "    \"average_outset_fee\": 0.25,\n" +
                        "    \"recommend_times\": 5\n" +
                        "  },\n" +
                        "  \"label_content\": {\n" +
                        "    \"REGION_ID\": \"8510400\",\n" +
                        "    \"USER_IS_SPEEDDOWD_D\": 1,\n" +
                        "    \"black_mark_flag\": \"0\",\n" +
                        "    \"B85110A0200103140\": 15.0,\n" +
                        "    \"B85110A0200103141\": 1,\n" +
                        "    \"B85110A0200103133\": \"2023-03-23 14:58:18\",\n" +
                        "    \"serv_id\": \"620043318599\",\n" +
                        "    \"T_SCS_SFBXLTC\": 1,\n" +
                        "    \"T10000001\": \"18081738100\",\n" +
                        "    \"T10000002\": \"620021291100\",\n" +
                        "    \"tid\": \"620043318593\",\n" +
                        "    \"red_mark_flag\": \"0\",\n" +
                        "    \"B85110A0200101708\": \"HuangGuiChun\",\n" +
                        "    \"B85110A0200103135\": 21.5,\n" +
                        "    \"custId\": \"620021291100\",\n" +
                        "    \"link_acc_nbr\": \"18081738100\",\n" +
                        "    \"B85110A0200103134\": \"2023-01-23 14:58:18\",\n" +
                        "    \"B85110A0200103137\": 29.5,\n" +
                        "    \"B85110A0200103136\": 100.0,\n" +
                        "    \"B85110A0200103139\": 20.0,\n" +
                        "    \"tp\": 1,\n" +
                        "    \"B85110A0200103138\": 25.5,\n" +
                        "    \"LINK_NBR\": \"18081738100\",\n" +
                        "    \"B85110B0200101980\": \"wm3UnLCAAAJnrvBqIAohz0bMdmOY_OkQ\"\n" +
                        "  }\n" +
                        "}";
                ProducerRecord<String, String> producerRecord = new ProducerRecord<>("bss-rta-rule-flink-dev-0", data);
                producer.send(producerRecord);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        producer.close();

    }

    private static void test2() {
        //1.创建kafka生产者配置对象
        Properties props = new Properties();
        //2.给 kafka 配置对象添加配置信息：bootstrap.servers
//        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.15:6667,192.168.10.16:6667,192.168.10.17:6667");
        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.156:6667,192.168.10.157:6667,192.168.10.158:6667");
        //key,value 序列化（必须）
        //把发送的key从字符串序列化为字节数组
        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        //把发送消息value从字符串序列化为字节数组
        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        props.put(ProducerConfig.ACKS_CONFIG, "all");
        // 3. 创建 kafka 生产者对象
        Producer<String, String> producer = new KafkaProducer<>(props);


        for (int i = 0; i < 2000000; i++) {
            //4. 调用 send 方法,发送消息
            RecordMetadata metadata = null;
            try {
                Map data = new HashMap();
                data.put("msisdn", RandomUtil.randomLong(13000000000L, 13999999999L));
//                data.put("msisdn",i+0L);
                data.put("tjdate", new Date());
                data.put("qq_click", RandomUtil.randomLong(0L, 10L));
                data.put("wyyyy_click", RandomUtil.randomLong(0L, 10L));
                data.put("kg_click", RandomUtil.randomLong(0L, 10L));
                data.put("dy_click", RandomUtil.randomLong(0L, 10L));
                data.put("ks_click", RandomUtil.randomLong(0L, 10L));
                data.put("xhs_click", RandomUtil.randomLong(0L, 10L));
                data.put("jy_click", RandomUtil.randomLong(0L, 10L));
                data.put("bdwp_click", RandomUtil.randomLong(0L, 10L));
                data.put("alyp_click", RandomUtil.randomLong(0L, 10L));
                data.put("xl_click", RandomUtil.randomLong(0L, 10L));
                data.put("transactionId", UUID.fastUUID().toString(true));
                ProducerRecord<String, String> producerRecord = new ProducerRecord<>("haigao_ceshi", JSONUtil.toJSONString(data));
                producer.send(producerRecord);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        producer.close();

    }

    private static void test1() {
        //1.创建kafka生产者配置对象
        Properties props = new Properties();
        //2.给 kafka 配置对象添加配置信息：bootstrap.servers
        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.15:6667,192.168.10.16:6667,192.168.10.17:6667");
//        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.156:6667,192.168.10.157:6667,192.168.10.158:6667");
        //key,value 序列化（必须）
        //把发送的key从字符串序列化为字节数组
        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        //把发送消息value从字符串序列化为字节数组
        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        props.put(ProducerConfig.ACKS_CONFIG, "all");
        // 3. 创建 kafka 生产者对象
        Producer<String, String> producer = new KafkaProducer<>(props);
//        List<String> strings = FileUtil.readLines("/Users/yzb/Desktop/source-code/02.git/flink-sql-submit/src/main/resources/user_behavior.log", "utf-8");
//        FileUtil.readUtf8Lines(new File("/Users/yzb/Desktop/source-code/02.git/flink-sql-submit/src/main/resources/user_behavior.log"), new LineHandler() {
//            @Override
//            public void handle(String line) {
//                ProducerRecord<String, String> producerRecord = new ProducerRecord<>("user_behavior", line);
//                try {
//                    producer.send(producerRecord).get();
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                } catch (ExecutionException e) {
//                    throw new RuntimeException(e);
//                }
//
//            }
//        });


        for (int i = 0; i < 20000000; i++) {
            //4. 调用 send 方法,发送消息
            RecordMetadata metadata = null;
            try {
                UserBehavior userBehavior = new UserBehavior();
//                userBehavior.setUserId(RandomUtil.randomString("abcbef",1));
                userBehavior.setUserId("" + i);
                userBehavior.setUserId1(RandomUtil.randomString("ghijklm", 1));
                userBehavior.setUserId2(RandomUtil.randomString("nopqr", 1));
                userBehavior.setUserId3(RandomUtil.randomString("stuv", 1));
                userBehavior.setUserId4(RandomUtil.randomString("wxyz", 1));
                userBehavior.setItemId(RandomUtil.randomString(10));
                userBehavior.setCategoryId(RandomUtil.randomString(10));
                userBehavior.setBehavior(RandomUtil.randomString(10));
                userBehavior.setTs(DateUtil.parseDateTime("2023-02-22 17:" + RandomUtil.randomInt(10, 59) + ":" + RandomUtil.randomInt(10, 59)));
                ProducerRecord<String, String> producerRecord = new ProducerRecord<>("flink_test_4", JSONUtil.toJSONString(userBehavior));
                producer.send(producerRecord);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        producer.close();
        //=====阻塞=======
//        System.out.println("同步方式发送消息结果：" + "topic-" + metadata.topic() + "|partition-" + metadata.partition() + "|offset-" + metadata.offset());

    }


    private static void tongji() {
        String content = "{\n" +
                "    \"transactionId\": \"{transactionId}\",\n" +
                "    \"upTransactionId\": \"{upTransactionId}\",\n" +
                "    \"eventId\": {eventId},\n" +
                "    \"subSceneId\": {subSceneId},\n" +
                "    \"busiEventId\": {busiEventId},\n" +
                "    \"dealResult\": {dealResult},\n" +
                "    \"fromContent\": \"{\\\"evtId\\\":\\\"{eventId}\\\",\\\"evtMsgContent\\\":\\\"{\\\\\\\"event_prodInstId\\\\\\\":\\\\\\\"340067630924\\\\\\\",\\\\\\\"event_regionId\\\\\\\":\\\\\\\"8421100\\\\\\\",\\\\\\\"event_custId\\\\\\\":\\\\\\\"340011217887\\\\\\\",\\\\\\\"event_accNbr\\\\\\\":\\\\\\\"18140625467\\\\\\\",\\\\\\\"busiRepOfferName\\\\\\\":\\\\\\\"存20元得50元话费（政企）\\\\\\\",\\\\\\\"ordCompDate\\\\\\\":\\\\\\\"20230221094806\\\\\\\",\\\\\\\"handleChannelName\\\\\\\":\\\\\\\"黄冈维达通电渠代理\\\\\\\",\\\\\\\"event_custName\\\\\\\":\\\\\\\"杨**(先生)\\\\\\\",\\\\\\\"event_evtSrcId\\\\\\\":\\\\\\\"415\\\\\\\",\\\\\\\"offerHandleTyp\\\\\\\":\\\\\\\"1000\\\\\\\",\\\\\\\"event_priorityLinkPhone\\\\\\\":\\\\\\\"无\\\\\\\",\\\\\\\"offerEffDate\\\\\\\":\\\\\\\"20230221094805\\\\\\\"}\\\"}\",\n" +
                "    \"toContent\": \"{\\\"evtId\\\":\\\"{eventId}\\\",\\\"evtMsgContent\\\":\\\"{\\\\\\\"event_prodInstId\\\\\\\":\\\\\\\"340067630924\\\\\\\",\\\\\\\"event_regionId\\\\\\\":\\\\\\\"8421100\\\\\\\",\\\\\\\"event_custId\\\\\\\":\\\\\\\"340011217887\\\\\\\",\\\\\\\"event_accNbr\\\\\\\":\\\\\\\"18140625467\\\\\\\",\\\\\\\"busiRepOfferName\\\\\\\":\\\\\\\"存20元得50元话费（政企）\\\\\\\",\\\\\\\"ordCompDate\\\\\\\":\\\\\\\"20230221094806\\\\\\\",\\\\\\\"handleChannelName\\\\\\\":\\\\\\\"黄冈维达通电渠代理\\\\\\\",\\\\\\\"event_custName\\\\\\\":\\\\\\\"杨**(先生)\\\\\\\",\\\\\\\"event_evtSrcId\\\\\\\":\\\\\\\"415\\\\\\\",\\\\\\\"offerHandleTyp\\\\\\\":\\\\\\\"1000\\\\\\\",\\\\\\\"event_priorityLinkPhone\\\\\\\":\\\\\\\"无\\\\\\\",\\\\\\\"offerEffDate\\\\\\\":\\\\\\\"20230221094805\\\\\\\"}\\\"}\",\n" +
                "    \"fromTs\": \"2023-02-21 11:28:02.974\",\n" +
                "    \"toTs\": \"2023-02-21 11:28:02.974\",\n" +
                "    \"fromConfig\": \"topic:taocanbiangeng_yw\",\n" +
                "    \"toConfig\": \"topic:evt_source_center_mid\",\n" +
                "    \"id\": \"{id}\",\n" +
                "    \"type\": \"{type}\"\n" +
                "}";
        //1.创建kafka生产者配置对象
        Properties props = new Properties();
        //2.给 kafka 配置对象添加配置信息：bootstrap.servers
        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.10.156:6667,192.168.10.157:6667,192.168.10.158:6667");
        //key,value 序列化（必须）
        //把发送的key从字符串序列化为字节数组
        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        //把发送消息value从字符串序列化为字节数组
        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        props.put(ProducerConfig.ACKS_CONFIG, "all");
        // 3. 创建 kafka 生产者对象
        Producer<String, String> producer = new KafkaProducer<>(props);
        Integer[] types = new Integer[]{1000, 2000, 3000};
        for (int i = 0; i < 20000000; i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("transactionId", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + i);
            map.put("upTransactionId", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + i);
            map.put("id", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + i);
            map.put("type", types[RandomUtil.randomInt(0, 3)]);
            map.put("eventId", RandomUtil.randomInt(100001, 100010));
            map.put("subSceneId", RandomUtil.randomInt(200001, 200010));
            map.put("busiEventId", RandomUtil.randomInt(300001, 300010));
            map.put("dealResult", RandomUtil.randomInt(0, 2));
            String format = StrUtil.format(content, map);
            ProducerRecord<String, String> producerRecord = new ProducerRecord<>("flink_test_8", format);
            producer.send(producerRecord);
        }
    }
}

